<template>
  <div>
    <el-card>
      <div slot="header">
        <span>我的评论</span>
      </div>
      <el-empty v-if="!myComment" description="空空如也！" style="height: 467px;"></el-empty>
      <div v-else v-for="item in this.myComment" :key="item.id" class="text item">
        <div class="cloudN-center-content-text">
          <i class="el-icon-time"></i>
          <span class="cloudN-center-content-time">{{ item.creat_time }}</span>
        </div>
        <a href="">
          <div class="cloudN-center-content-title">{{ item.article.title }}</div>
          <div class="cloudN-center-content-text2">回复帖子：{{ item.content }}</div>
        </a>
        <el-divider></el-divider>
      </div>
    </el-card>
  </div>
</template>

<script>
export default {
  data () {
    return {
      myComment: []
    }
  },
  created () {
    this.getMycomment()
  },
  // DOM对象加载完成时
  mounted () {
  },
  methods: {
    async getMycomment () {
      const url = this.$config.urls.get('load_user_comment')
      const { data: res } = await this.$http.post(url)
      if (res.code !== 0) {
        this.$message.error('用户未登录！')
        // console.log(res)
      } else {
        // console.log(res.data)
        res.data.forEach(item => {
          item.creat_time = this.$date.diffTime(item.creat_time)
        })
        this.myComment = res.data
      }
    }
  },
  computed: {},
  name: 'userArticle'
}
</script>

<style lang="less" scoped>

</style>
